package com.mmc.common.result;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 响应状态码枚举
 *
 * @author kunfe
 * @since 2024-01-01
 */
@Getter
@AllArgsConstructor
public enum ResultCode {

    // 成功
    SUCCESS(200, "操作成功"),

    // 客户端错误
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不支持"),
    CONFLICT(409, "数据冲突"),
    UNPROCESSABLE_ENTITY(422, "请求参数校验失败"),
    TOO_MANY_REQUESTS(429, "请求过于频繁"),

    // 服务器错误
    INTERNAL_ERROR(500, "服务器内部错误"),
    BAD_GATEWAY(502, "网关错误"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),

    // 业务错误
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_DISABLED(1002, "用户已被禁用"),
    USERNAME_EXISTS(1003, "用户名已存在"),
    EMAIL_EXISTS(1004, "邮箱已存在"),
    PHONE_EXISTS(1005, "手机号已存在"),
    PASSWORD_ERROR(1006, "密码错误"),
    OLD_PASSWORD_ERROR(1007, "原密码错误"),
    PASSWORD_SAME(1008, "新密码不能与原密码相同"),
    
    ROLE_NOT_FOUND(1101, "角色不存在"),
    ROLE_EXISTS(1102, "角色已存在"),
    ROLE_HAS_USERS(1103, "角色下还有用户，无法删除"),
    
    MENU_NOT_FOUND(1201, "菜单不存在"),
    MENU_EXISTS(1202, "菜单已存在"),
    MENU_HAS_CHILDREN(1203, "菜单下还有子菜单，无法删除"),
    
    DEPT_NOT_FOUND(1301, "部门不存在"),
    DEPT_EXISTS(1302, "部门已存在"),
    DEPT_HAS_CHILDREN(1303, "部门下还有子部门，无法删除"),
    DEPT_HAS_USERS(1304, "部门下还有用户，无法删除"),
    
    FILE_NOT_FOUND(1401, "文件不存在"),
    FILE_UPLOAD_FAILED(1402, "文件上传失败"),
    FILE_TYPE_NOT_SUPPORTED(1403, "不支持的文件类型"),
    FILE_SIZE_EXCEEDED(1404, "文件大小超出限制"),
    
    DICT_NOT_FOUND(1501, "字典不存在"),
    DICT_EXISTS(1502, "字典已存在"),
    DICT_HAS_ITEMS(1503, "字典下还有字典项，无法删除"),
    
    NOTICE_NOT_FOUND(1601, "公告不存在"),
    
    MESSAGE_NOT_FOUND(1701, "消息不存在"),
    
    TASK_NOT_FOUND(1801, "任务不存在"),
    TASK_RUNNING(1802, "任务正在运行中"),
    TASK_PAUSED(1803, "任务已暂停"),
    
    CAPTCHA_ERROR(1901, "验证码错误"),
    CAPTCHA_EXPIRED(1902, "验证码已过期"),
    
    SMS_SEND_FAILED(2001, "短信发送失败"),
    SMS_LIMIT_EXCEEDED(2002, "短信发送次数超限"),
    EMAIL_SEND_FAILED(2003, "邮件发送失败"),
    
    CONFIG_NOT_FOUND(2101, "配置不存在");

    private final Integer code;
    private final String message;
} 